import request from '@/utils/request'

// 获取选课记录 (管理员查看所有，学生查看自己的)
export function getEnrollments(params) {
  return request({
    url: '/api/v1/enrollments',
    method: 'get',
    params
  })
}

// 学生选课
export function selectCourse(courseId) {
  return request({
    url: '/api/v1/enrollments/select',
    method: 'post',
    data: { courseId }
  })
}

// 学生退课
export function dropCourse(courseId) {
  return request({
    url: '/api/v1/enrollments/drop',
    method: 'post',
    data: { courseId }
  })
}

// 更新成绩 (教师)
export function updateGrade(enrollmentId, grade) {
  return request({
    url: `/api/v1/enrollments/${enrollmentId}/grade`,
    method: 'put',
    data: { grade }
  })
}

// 获取我的选课 (学生)
export function getMyEnrollments() {
  return request({
    url: '/api/v1/enrollments/my',
    method: 'get'
  })
}

// 强制退课 (管理员)
export function forceDropCourse(enrollmentId) {
  return request({
    url: `/api/v1/enrollments/${enrollmentId}`,
    method: 'delete'
  })
}

// 获取某课程的选课学生列表 (教师/管理员)
export function getCourseStudents(courseId, params) {
  return request({
    url: `/selections/course/${courseId}`,
    method: 'get',
    params
  })
}

// 获取所有选课记录 (管理员)
export function getAllSelections(params) {
  return request({
    url: '/selections',
    method: 'get',
    params
  })
}

// 获取课程选课记录 (教师/管理员)
export function getCourseSelections(params) {
  return request({
    url: '/api/v1/enrollments',
    method: 'get',
    params
  })
} 